<?php
include('../mysqli_connect.php');
$sqlWinRate = "select team_name,win_rate from team;";
$resWinRate = mysqli_query($dbc, $sqlWinRate);
$winRateArray = array();
$i = 0;
while ($row = mysqli_fetch_row($resWinRate)) {
  $winRateArray[$i]['name'] = $row[0];
  $winRateArray[$i]['value'] = $row[1];
  $i = $i + 1;
}

$sqlVote = "select t.team_name,count(*) from team t,user u where u.vote_team=t.team_id group by t.team_id;";
$resVote = mysqli_query($dbc, $sqlVote);
$voteArray = array();
$i = 0;
while ($row = mysqli_fetch_row($resVote)) {
  $voteArray[$i]['name'] = $row[0];
  $voteArray[$i]['value'] = $row[1];
  $i = $i + 1;
}


$response = array('status' => true, 'winRate' => $winRateArray, 'voteTeam' => $voteArray);
echo json_encode($response);
